/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-05-26 21:34:29
 * @LastEditTime: 2024-09-05 20:38:44
 * @FilePath: /nest_study/server/src/common/dto/index.dto.ts
 */
import { ApiProperty } from "@nestjs/swagger";
import { IsEmpty, IsEnum, IsNotEmpty, IsNumber, IsNumberString, IsOptional, IsString, Length, Min } from "class-validator";
import { SYS_STATUS } from "../enum/status";
import { Transform, Type } from "class-transformer";


//基础信息
export class BaseInfoDto {
    @IsOptional()
    @IsNumber()
    sort?: number;

    @IsOptional()
    @IsString()
    @Length(0, 500)
    remark?: string;

    @IsOptional()
    @IsString()
    @IsEnum(SYS_STATUS)
    status?: string;

    @ApiProperty({ required: false })
    @IsOptional()
    @IsString()
    @Length(0, 500)
    createBy?: string;

    @ApiProperty({ required: false })
    createTime?: Date;

    @ApiProperty({ required: false })
    @IsOptional()
    @IsString()
    @Length(0, 500)
    updateBy?: string;

    @ApiProperty({ required: false })
    updateTime?: Date;
}
/**
 * 分页Dto
 */
export class PaginationDto {
    @ApiProperty({ type: Number, required: true, default: 1, description: "页码" })
    @Transform(({ value }) => Number(value))
    @IsNumber({}, { message: '请输入有效的页码' })
    @Min(1, { message: '页码最小为1' })
    @IsNotEmpty({
        message: '页码不能为空',
    })
    page: number = 1;

    @ApiProperty({ type: Number, required: true, default: 10, description: "每页数量" })
    @Transform(({ value }) => Number(value))
    @IsNumber({}, { message: '请输入有效的条数' })
    @Min(1, { message: '条数最小为1' })
    @IsNotEmpty({
        message: '条数不能为空',
    })
    size: number = 10;

    @ApiProperty({ required: false })
    @IsOptional()
    @IsString()
    startTime: string;

    @ApiProperty({ required: false })
    @IsOptional()
    @IsString()
    endTime: string;

    //     /**
    //      * 排序字段
    //      */
    //     @ApiProperty({ required: false })
    //     @IsOptional()
    //     @IsString()
    //     orderByColumn: string;

    //     /**
    //    * 排序规则
    //    */
    //     @ApiProperty({ required: false })
    //     @IsOptional()
    //     @IsString()
    //     isAsc?: 'ascending' | 'descending';

}